<template>
    <Modal
            v-model="modal"
            :width="80"
            :title="title">
        <div v-if='modal'>
            <div class="table-responsive"  v-if='list'>
                <table class="vm table color-bordered-table base-bordered-table table-bordered table-hover">
                    <thead>
                    <tr class="nowrap">
                        <!--<th>ID</th>-->
                        <th>姓名</th>
                        <th>电话</th>
                        <th>重复数据</th>
                    </tr>
                    </thead>
                    <tbody  v-show='list.length'>
                    <tr v-for="(item,key) in list">
                        <!--<td>{{item.id}}</td>-->
                        <td>{{item.name}}</td>
                        <td>{{item.phone}}</td>
                        <td>{{item.multiple}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div slot="footer">
            <Button type="text" @click='cancel'>关闭</Button>
            <Button type="ghost" @click='noSubmit'>取消提交</Button>
            <Button type="success" @click='okSubmit'>去重提交</Button>
            <btn-submit :p-click='ok'>确定全部提交</btn-submit>
        </div>
    </Modal>
</template>
<script>
    const setDataDef = {
        worker_id:''
    };
    import serCustomer from '../../serves/api-customer'
    import serWorkerWrite from '../../serves/api-worker-write'
    export default{
        data () {
            return {
                list:[],
                modal: false,
                info:{},
            }
        },
        computed:{
            title(){
                return '导入参会人员存在重复数据，是否确认提交审核'
            }
        },
        methods: {
            handleOpen(data){
                this.info = Object.assign({},setDataDef,data);
                this.listInit();
                this.$set(this,'modal',true);
            },
            async listInit(){
                let res = await serWorkerWrite.getVerityRepeatData({
                    id:this.info.id
                });
                if(res.code==1){
                    this.list = res.data;
                }else {
                    this.$Message.error(res.message)
                }
            },
            async ok () {
                const res = await serWorkerWrite.OkVerityRepeatSubmit({
                    id:this.info.id
                });
                if(res.code==1){
                    this.$Message.success(res.message);
                    this.$set(this,'modal',false);
                    this.$emit('on-change',true);
                    return true;
                }else{
                    this.$Message.error(res.message);
                    return false;
                }
            },
            async noSubmit () {
                const res = await serWorkerWrite.NoVerityRepeatSubmit({
                    id:this.info.id
                });
                if(res.code==1){
                    this.$Message.success(res.message);
                    this.$set(this,'modal',false);
                    this.$emit('on-change',true);
                    return true;
                }else{
                    this.$Message.error(res.message);
                    return false;
                }
            },
            async okSubmit () {
                const res = await serWorkerWrite.unRepeatVerityRepeatSubmit({
                    id:this.info.id
                });
                if(res.code==1){
                    this.$Message.success(res.message);
                    this.$set(this,'modal',false);
                    this.$emit('on-change',true);
                    return true;
                }else{
                    this.$Message.error(res.message);
                    return false;
                }
            },
            cancel () {
                this.$set(this,'modal',false);
                this.$emit('on-change',false);
            },
        },
        components:{
        }
    }
</script>